package com.mhsoft.fenak;

import java.util.ArrayList;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

import android.app.Activity;
import android.app.Dialog;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;

import com.mhsoft.fenak.utils.ConnectionManager;
import com.mhsoft.fenak.utils.Constants;
import com.mhsoft.fenak.utils.TextValidation;

public class forgetPassDialog extends Dialog implements OnClickListener {

	private Button okButton, cancelButton;
	private EditText emailEditText;
	private Activity context;
	
	public forgetPassDialog(Activity context) {
		super(context);
		this.context=context;
//		LayoutInflater factory = LayoutInflater.from(context);
//		View view = factory.inflate(R.layout.dialog_forget_pass, null); 
//		LinearLayout layout = (LinearLayout) view.findViewById(R.id.dialog_layout);

		requestWindowFeature(Window.FEATURE_NO_TITLE);      
	    setContentView(R.layout.dialog_forget_pass);
	    setCanceledOnTouchOutside(true);
		
		okButton=(Button)findViewById(R.id.forgetpass_commit_Button);
		cancelButton=(Button)findViewById(R.id.forgetpass_cancel_button);
		
		okButton.setOnClickListener(this);
		cancelButton.setOnClickListener(this);
		
		emailEditText=(EditText)findViewById(R.id.forgetpass_email_editText);
	}

	@Override
	public void onClick(View v) {
		if(v==okButton){
			if(TextValidation.validateSignIn(context, emailEditText.getText().toString(),"asllakdfjladfj")){
//				ArrayList<NameValuePair> dataString=new ArrayList<NameValuePair>();
//				dataString.add(new BasicNameValuePair("user_email",emailEditText.getText().toString()));
//				ConnectionManager.doPostRequest(context, "Forget Password", "Please wait...", Constants.URL_FORGET_PASS, "2", dataString);
				ConnectionManager.doGetRequest(context, "Sending Request", "Please wait..."
					,Constants.URL_FORGET_PASS+"?email="+emailEditText.getText().toString(),"2");
				dismiss();
			}
		}else if(v==cancelButton){
			dismiss();
		}
	}

}
